import { createRouter, createWebHistory } from 'vue-router'

import {routes} from "./routes"

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

router.beforeEach((to: any, from: any, next: any) => {
  console.log(to, from);
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;

  // 兼容IE
  window.scrollTo(0, 0);
  next();
})

export default router